﻿<classes:MSHPhoneApplicationPage 
    x:Class="WP7Client.UserInterface.Pages.ProfilePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.WP7"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:classes="clr-namespace:WP7Client.Classes"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" Loaded="MSHPhoneApplicationPage_Loaded">
    <classes:MSHPhoneApplicationPage.Resources>
        <classes:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter"/>
        <classes:IsFriendConverter x:Key="IsFriendConverter" />
        <classes:CanChatConverter x:Key="CanChatConverter" />
        <classes:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    </classes:MSHPhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot">
        <controls:Pivot Title="MY SOCIAL HUB PROFILE" Visibility="{Binding Path=Loading, ElementName=PivotItem, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=invert}">
            <controls:PivotItem Header="{Binding FullName}" Name="PivotItem">
                <ListBox>
                    <Grid Width="460">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" Background="{StaticResource PhoneAccentBrush}">
                            <TextBlock Text="Profile" Margin="10,4,0,4" FontSize="40" Style="{StaticResource TextBlockStyle}"/>
                        </Border>                        
                        <StackPanel Grid.Row="1" Visibility="{Binding Path=DataContext.UserProfile.FirstName, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="First name:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.FirstName, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="2" Visibility="{Binding Path=DataContext.UserProfile.SurName, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Sur name:" />
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.SurName, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="3" Visibility="{Binding Path=DataContext.UserProfile.MobilePhoneNumber, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Mobile phone number:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.MobilePhoneNumber, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="4" Visibility="{Binding Path=DataContext.UserProfile.Address, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Address:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.Address, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="5" Visibility="{Binding Path=DataContext.UserProfile.Zipcode, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Zipcode:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.Zipcode, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="6" Visibility="{Binding Path=DataContext.UserProfile.City, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="City:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.City, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="7" Visibility="{Binding Path=DataContext.UserProfile.Sex, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Sex:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.Sex, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="8" Visibility="{Binding Path=DataContext.UserProfile.DateOfBirth, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Date of birth:"/>
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.DateOfBirth, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="9" Visibility="{Binding Path=DataContext.UserProfile.Website, ElementName=PivotItem, Converter={StaticResource ObjectToVisibilityConverter}}">
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="Website:" />
                            <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Path=DataContext.UserProfile.Website, ElementName=PivotItem}" Margin="20,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="10" Orientation="Horizontal">
                            <Button Content="Chat" Visibility="{Binding Path=DataContext.Username, ElementName=PivotItem, Converter={StaticResource CanChatConverter}}" 
                                    cmd:ButtonBaseExtensions.Command="{Binding Path=DataContext.ChatCommand, ElementName=PivotItem}" cmd:ButtonBaseExtensions.CommandParameter="{Binding Path=DataContext.Username, ElementName=PivotItem}"/>
                            <Button Content="Send invitation" Visibility="{Binding Path=DataContext.Username, ElementName=PivotItem, Converter={StaticResource IsFriendConverter}, ConverterParameter=invert}"
                                    cmd:ButtonBaseExtensions.Command="{Binding Path=DataContext.SendInvitationCommand, ElementName=PivotItem}" cmd:ButtonBaseExtensions.CommandParameter="{Binding Path=DataContext.Username, ElementName=PivotItem}"/>    
                        </StackPanel>
                    </Grid>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
        <ProgressBar VerticalAlignment="Top" IsIndeterminate="{Binding Path=Loading, ElementName=PivotItem}"/>
    </Grid>

</classes:MSHPhoneApplicationPage>
